﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.Reflection;
namespace LiveWCFServiceTests
{
    public abstract class ServiceTestBase<T>
    {
        protected abstract string ServiceLocation { get; }
        protected virtual T CreateService(CustomBinding Binding, EndpointAddress Endpoint)
        {
            try
            {
                return (T)Activator.CreateInstance(typeof(T), Binding, Endpoint);
            }
            catch (Exception)
            {

                throw new Exception("The type specified does not match the standard definition for a service client, consider overriding CreateService method.");
            }
        }
        protected T Client { get { return TestConfiguration.LoadService(ServiceLocation, CreateService); } }

    }
}
